# -*- coding: utf-8 -*-
from django.db import models
from django.db.models import Manager


class TableModel(models.Model):
    char_field = models.CharField(choices=(('Y', 'YES',), ('N', 'NO'),), )
    decimal_field = models.DecimalField(max_digits=16, decimal_places=4)
    json_field = models.JSONField()

    class Meta:
        db_table = 'api_table'
        verbose_name = '表格'
        verbose_name_plural = verbose_name


class BaseModel(models.Model):
    delete_flag = models.BinaryField(default=0, max_length=1, verbose_name='是否删除',
                                     choices=((0, '未删除',), (1, '已删除'),), )
    objects = Manager()

    class Meta:
        abstract = True

    def __str__(self):
        if hasattr(self, 'name'):
            return self.name
        return self.pk


from django.db import models


class Person(models.Model):
    name = models.CharField(max_length=128, verbose_name='名称', )
    status = models.IntegerField(verbose_name='状态', )
    birthday = models.DateField(default='2000-01-01', verbose_name='生日', )

    class Meta:
        abstract = True
        pass

    pass


class Worker(Person):
    position = models.CharField(max_length=128, verbose_name='职位', )
    department = models.CharField(max_length=128, verbose_name='部门', )

    class Meta:
        db_table = 'app_worker'
        verbose_name = '工人'
        verbose_name_plural = verbose_name
        pass

    pass


class Farmer(Person):
    department = models.CharField(max_length=128, verbose_name='部门', )

    class Meta:
        db_table = 'app_farmer'
        verbose_name = '工人'
        verbose_name_plural = verbose_name
        pass

    pass